/*
    Android UIML

	Copyright (C) 2010  Bram Goffings (bramgoffings@gmail.com)

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU Lesser General Public License
	as published by the Free Software Foundation; either version 2.1
	of	the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Lesser General Public License for more details.

	You should have received a copy of the GNU Lesser General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

package uiml.android.elements.peers;

import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;

import uiml.android.elements.IUimlAttribute;
import uiml.android.elements.UimlElement;

public class Script extends UimlElement implements IUimlAttribute{
	
	// TODO comment
	private String script = null; 
	
	private String type = null;

	// TODO comment
	public static String IAM = "script";
	public final String TYPE = "type";
	
	/**
	 * 
	 * @param node
	 */
	public Script(Element node) {
		super(node);
		process();
	}

	/**
	 * 
	 */
	@Override
	protected Object clone() {
		// TODO Auto-generated method stub
		return null;
	}
	
	/**
	 * 
	 */
	@Override
	public void process() {
		processAttributes();
		script = node.getNodeValue();
	}
	
	/**
	 * 
	 */
	@Override
	public void processAttributes() {
		
		NamedNodeMap attributes = node.getAttributes();
		
		if(attributes != null) {
			if(attributes.getNamedItem(TYPE) != null)
				setType(attributes.getNamedItem(TYPE).getNodeValue());
			else
				System.out.println("Warning: " + IAM + " should have \"" + TYPE + "\" attribute!");
		}
	}


	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @param script the script to set
	 */
	public void setScript(String script) {
		this.script = script;
	}

	/**
	 * @return the script
	 */
	public String getScript() {
		return script;
	}

}
